package com.wubo.sec.service;

import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.annotation.security.RolesAllowed;

import com.wubo.sec.filter.IFilterResourceLoader;
import com.wubo.sec.model.Authority;
import com.wubo.sec.model.Menu;

/**
 * 
 * @author wubo
 * @CreateDate 2010-7-31
 * @version 1.0.01
 */
public interface IMenuService extends IFilterResourceLoader {
	@RolesAllowed({"ADMIN", "MENU_READ"})
	List<String> listName(String name);
	
	@RolesAllowed({"ADMIN", "MENU_ADD"})
	String create(Menu menu);
	
	@RolesAllowed({"ADMIN", "MENU_UPDATE"})
	Menu update(Menu menu);
	
	@RolesAllowed({"ADMIN", "MENU_UPDATE"})
	/**
	 * 更新菜单树结构关系
	 * 用于单个菜单树节点结构调整
	 */
	void updateStruct(String code, String originParentCode, String newParentCode, int nodeIndex);
	@RolesAllowed({"ADMIN", "MENU_UPDATE"})
	/**
	 * 保存菜单树结构关系
	 * 用于整棵菜单树结构调整
	 */
	void saveStruct(List<Map<String, ?>> list);
	
	@RolesAllowed({"ADMIN", "MENU_DELETE"})
	void delete(Menu menu);
	
	@RolesAllowed({"ADMIN", "MENU_DELETE"})
	void delete(String[] codes);
	
	@RolesAllowed({"ADMIN", "MENU_READ"})
	List<Menu> findAll(String where, Object... params);
	
	@RolesAllowed({"ADMIN", "MENU_READ"})
	Set<Menu> findAllTree(boolean onlyActive);
	
	Set<Menu> findAllTreeRunAs();

	@RolesAllowed({"ADMIN", "MENU_READ"})
	List<Menu> getSplitPage(int start, int limit, String where, Object... params);
	
	@RolesAllowed({"ADMIN", "MENU_READ"})
	long getTotal(String where, Object... params);
	
	Set<Menu> getMenuTree(Authority[] authorities);
	
	Set<Menu> getMenuTree(String[] authorityCodes);
	
	Menu get(String code);
	
}
